package com.lkm.app_ui.ui.fj.to;

import com.google.gson.annotations.SerializedName;
import com.lkm.app_ui.ui.fj.FjOrder;
import com.lkm.javatool.CollectionHelp;

import java.util.ArrayList;
import java.util.List;

public class FjOrderTo {

    public static FjOrderTo by(FjOrder fjOrder) {
        List<FjOrder.FjItem> fjItems = fjOrder.fjItems;
        if(fjItems!=null)
            fjItems = new ArrayList<>(fjItems);
        FjOrderItemTo[] order_goods = new FjOrderItemTo[CollectionHelp.getSize(fjItems)];
        for (int i = 0; i < order_goods.length; i++) {
            order_goods[i] = FjOrderItemTo.by(fjOrder.fjInfoNo, fjItems.get(i));
        }

        return new FjOrderTo(fjOrder.fjInfoNo, fjOrder.createTime, order_goods);
    }

    public FjOrderTo() {
    }

    public FjOrderTo(String order_no, String create_time, FjOrderItemTo[] order_goods) {
        this.order_no = order_no;
        this.create_time = create_time;
        this.order_goods = order_goods;
    }

    @SerializedName("address")
    public String address;

    @SerializedName("order_no")
    public String order_no;
    @SerializedName("create_time")
    public String create_time;

    @SerializedName("order_goods")
    public FjOrderItemTo[] order_goods;

}